flowbox: Export gtk_flow_box_get_child_at_pos as public API
authorDebarshi Ray <debarshir@gnome.org>
Fri, 16 Dec 2016 23:30:39 +0000 (00:30 +0100)
committerDebarshi Ray <debarshir@gnome.org>
Mon, 19 Dec 2016 23:35:17 +0000 (00:35 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=776187

docs/reference/gtk/gtk4-sections.txt
gtk/gtkflowbox.c
gtk/gtkflowbox.h

index abc11838d09d5b40084be4f2f69d3795f0cc08d3..aff537c030964286e996f44e43606d7b712fbc91 100644 (file)
@@ -6589,6 +6589,7 @@ GtkFlowBox
 gtk_flow_box_new
 gtk_flow_box_insert
 gtk_flow_box_get_child_at_index
+gtk_flow_box_get_child_at_pos
 gtk_flow_box_set_hadjustment
 gtk_flow_box_set_vadjustment
 
index eb448795a4766de0fbed62f44206b443c15dc406..f1e7af1b351dba4a0c7fc3ec24ad0b176b086bb8 100644 (file)
@@ -856,31 +856,6 @@ get_visible_children (GtkFlowBox *box)
   return i;
 }
 
-static GtkFlowBoxChild *
-gtk_flow_box_get_child_at_pos (GtkFlowBox *box,
-                               gint        x,
-                               gint        y)
-{
-  GtkWidget *child;
-  GSequenceIter *iter;
-  GtkAllocation allocation;
-
-  for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
-       !g_sequence_iter_is_end (iter);
-       iter = g_sequence_iter_next (iter))
-    {
-      child = g_sequence_get (iter);
-      if (!child_is_visible (child))
-        continue;
-      gtk_widget_get_allocation (child, &allocation);
-      if (x >= allocation.x && x < (allocation.x + allocation.width) &&
-          y >= allocation.y && y < (allocation.y + allocation.height))
-        return GTK_FLOW_BOX_CHILD (child);
-    }
-
-  return NULL;
-}
-
 static void
 gtk_flow_box_update_active (GtkFlowBox      *box,
                             GtkFlowBoxChild *child)
@@ -4278,6 +4253,45 @@ gtk_flow_box_get_child_at_index (GtkFlowBox *box,
   return NULL;
 }
 
+/**
+ * gtk_flow_box_get_child_at_pos:
+ * @box: a #GtkFlowBox
+ * @x: the x coordinate of the child
+ * @y: the y coordinate of the child
+ *
+ * Gets the child in the (@x, @y) position.
+ *
+ * Returns: (transfer none) (nullable): the child widget, which will
+ *     always be a #GtkFlowBoxChild or %NULL in case no child widget
+ *     exists for the given x and y coordinates.
+ *
+ * Since: 3.22.6
+ */
+GtkFlowBoxChild *
+gtk_flow_box_get_child_at_pos (GtkFlowBox *box,
+                               gint        x,
+                               gint        y)
+{
+  GtkWidget *child;
+  GSequenceIter *iter;
+  GtkAllocation allocation;
+
+  for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
+       !g_sequence_iter_is_end (iter);
+       iter = g_sequence_iter_next (iter))
+    {
+      child = g_sequence_get (iter);
+      if (!child_is_visible (child))
+        continue;
+      gtk_widget_get_allocation (child, &allocation);
+      if (x >= allocation.x && x < (allocation.x + allocation.width) &&
+          y >= allocation.y && y < (allocation.y + allocation.height))
+        return GTK_FLOW_BOX_CHILD (child);
+    }
+
+  return NULL;
+}
+
 /**
  * gtk_flow_box_set_hadjustment:
  * @box: a #GtkFlowBox
index ff2a6be0daaf116c0a0c73d0044a3b88c7722975..fa059c37658de06a0ee5579c3e7b2a44d5664d8f 100644 (file)
@@ -181,6 +181,11 @@ GDK_AVAILABLE_IN_3_12
 GtkFlowBoxChild      *gtk_flow_box_get_child_at_index           (GtkFlowBox        *box,
                                                                  gint               idx);
 
+GDK_AVAILABLE_IN_3_22
+GtkFlowBoxChild      *gtk_flow_box_get_child_at_pos             (GtkFlowBox        *box,
+                                                                 gint               x,
+                                                                 gint               y);
+
 typedef void (* GtkFlowBoxForeachFunc) (GtkFlowBox      *box,
                                         GtkFlowBoxChild *child,
                                         gpointer         user_data);